package com.ticket.sass.common.printer.factory;


import com.ticket.sass.common.printer.context.SpringContextHolder;
import com.ticket.sass.common.printer.enums.PrinterType;
import com.ticket.sass.common.printer.service.PrinterService;

/**
 * 获取打印机服务类的工厂
 */
public class PrinterServiceFactory {
    private static final PrinterType printerType = PrinterType.YI_LIAN_YUN;
    
    /**
     * 根据 bean 名字获取实现
     *
     * @return
     */
    public static PrinterService getPrinterService(PrinterType printerType) {
        return SpringContextHolder.<PrinterService>getBean(printerType.getServiceName());
    }
    
    /**
     * 默认返回易联云实现
     *
     * @return
     */
    public static PrinterService getPrinterService() {
        return getPrinterService(printerType);
    }
}
